package com.ysd.ziyuanshiyongtongji.dao;

import java.util.Date;

import com.ysd.ziyuanshiyongtongji.model.ConsumeLog;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * IConsumeLogDao
 */
public interface IConsumeLogDao extends JpaRepository<ConsumeLog,Integer>{

    //查询会员最后一次进入资源室的日志编号
    @Query(value = "select * from consume_log where in_time = (select max(in_time) from consume_log where card_no = :cardNo)",nativeQuery = true)
    ConsumeLog getMaxInTime(String cardNo);

    //更新离开时间
    @Modifying//更新操作
    @Query(value = "update consume_log c set c.out_time= :outTime where c.id = :id",nativeQuery = true)
    int updateOutTime(int id,Date outTime);
}